package com.wk.springboot.config;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.Method;

public class LoggingInterceptor implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
//        System.out.println("Logging before calling method: " + invocation.getMethod().getName());
        Object result = invocation.proceed(); // 调用目标方法
        Method method = invocation.getMethod();
        String name = method.getName();
        System.out.println(name);
        System.out.println("Logging after calling method: " + invocation.getMethod().getName());
        return result;
    }
}
